﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

using OpenGL4NET;

namespace WSCore
{
	public class WSSprite : WSNode
	{
		private WSQuad _quad;
		private RectangleF _rect;

		public WSTexture2D Texture { get; set; }
		public WSQuad Quad { get { return _quad; } }
		public RectangleF Rect { get { return _rect; } }

		public WSSprite(WSTexture2D texture, RectangleF rect)
		{
			Texture = texture;

			PinPoint = new PointF(0.5f, 0.5f);
			Size = rect.Size;
			_rect = rect;

			WSColor color = new WSColor(255, 255, 255, 255);
			_quad = new WSQuad();

			_quad.LeftBottom.Color = color;
			_quad.RightBottom.Color = color;
			_quad.LeftTop.Color = color;
			_quad.RightTop.Color = color;

			float x1 = rect.X;
			float x2 = rect.X + rect.Width;
			float y1 = rect.Y;
			float y2 = rect.Y + rect.Height;

			_quad.LeftBottom.Vertex = new WSVertex(x1, y1, 0);
			_quad.LeftTop.Vertex = new WSVertex(x1, y2, 0);
			_quad.RightBottom.Vertex = new WSVertex(x2, y1, 0);
			_quad.RightTop.Vertex = new WSVertex(x2, y2, 0);

			_quad.LeftBottom.Tex = new WSTex(x1 / Texture.Width, y1 / Texture.Height);
			_quad.LeftTop.Tex = new WSTex(x1 / Texture.Width, y2 / Texture.Height);
			_quad.RightBottom.Tex = new WSTex(x2 / Texture.Width, y1 / Texture.Height);
			_quad.RightTop.Tex = new WSTex(x2 / Texture.Width, y2 / Texture.Height);
		}

		public override void Render()
		{
			
		}
	}
}
